import urllib.request
import urllib.parse
import urllib.error
import json

url = ('https://blog.csdn.net/2202_76097976/article/details/142544121')
# 当主机地址和参数出现问题的时候，就会报出URLError
# url = ('https://blog1.csdn.net/2202_76097976/article/details/142544121')

headers = {
    'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36'
}

try:
    request = urllib.request.Request(url, headers=headers)
    response = urllib.request.urlopen(request)
    html = response.read().decode('utf-8')
    print(html)
except urllib.error.HTTPError as e:
    print("请稍后，系统正在升级。。。")
except urllib.error.URLError as e:
    print("主机或参数出现问题，请检查参数。。。")
